let Printer = require('./printer-lib')
var spawn = require('child_process').spawn;
let rp = require('request-promise')
let printer = new Printer()
printer.start()
// printer.hello()
// // printer.write("HELLO")
setTimeout(function () {
  printer.write('tttt')
}, 10000)

exe(["/c", "java", "-jar", "printer-java-tool.jar"]);

function exe(command) {
  // windows下 
  var cmd = spawn("cmd", command);

  cmd.stdout.setEncoding("ASCII");
  cmd.stdout.on("data", function (data) {
    console.log("------------------------------");
    console.log("exec", command);
    console.log("stdout:" + data);
  });

  cmd.stderr.on("data", function (data) {
    console.log("------------------------------");
    console.log("stderr:" + data);
    console.log("------------------------------");
  });

  cmd.on("exit", function (code) {
    console.log("exited with code:" + code);
    console.log("------------------------------");
  });
};